package com.hxexp.weixin.mvc.common.service.impl;

import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.hxexp.weixin.mvc.common.service.TicketTypeService;

/**
 * 车票种类服务实现类
 *
 * @author li.jiang
 *
 */
@Service
public final class TicketTypeServiceImpl implements TicketTypeService {
    @Value("${ticket_type_disabled}")
    private String ticketTypeDisabledStartStationIds; // 支持军残半价票的车站编码
    @Value("${ticket_type_child}")
    private String ticketTypeChildStartStationIds; // 支持儿童半价票的车站编码
    @Value("${ticket_type_free}")
    private String ticketTypeFreeStartStationIds; // 支持携童免票的车站编码

    /* (non-Javadoc)
     * @see com.hxexp.weixin.mvc.common.service.TicketTypeService#isSellDisabledTicket(java.lang.String)
     */
    @Override
    public boolean isSellDisabledTicket(String startStationId) {
        List<String> ticketTypeDisabledStartStationIdList = Arrays.asList(ticketTypeDisabledStartStationIds.split(","));
        return ticketTypeDisabledStartStationIdList.contains(startStationId);
    }

    /* (non-Javadoc)
     * @see com.hxexp.weixin.mvc.common.service.TicketTypeService#isSellChildTicket(java.lang.String)
     */
    @Override
    public boolean isSellChildTicket(String startStationId) {
        List<String> ticketTypeChildStartStationIdList = Arrays.asList(ticketTypeChildStartStationIds.split(","));
        return ticketTypeChildStartStationIdList.contains(startStationId);
    }

    /* (non-Javadoc)
     * @see com.hxexp.weixin.mvc.common.service.TicketTypeService#isSellFreeTicket(java.lang.String)
     */
    @Override
    public boolean isSellFreeTicket(String startStationId) {
        List<String> ticketTypeFreeStartStationIdList = Arrays.asList(ticketTypeFreeStartStationIds.split(","));
        return ticketTypeFreeStartStationIdList.contains(startStationId);
    }

}
